import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../pages/HomePage.vue'),
      meta: {
        access: ['noAuth'],
      },
    },
    {
      path: '/user/login',
      name: 'login',
      component: () => import('../pages/user/UserLoginPage.vue'),
    },
    {
      path: '/user/register',
      name: 'register',
      component: () => import('../pages/user/UserRegisterPage.vue'),
    },
    {
      path: '/user/info',
      name: 'info',
      component: () => import('../pages/user/UserInfoPage.vue'),
      meta: {
        access: ['user'],
      },
    },
    {
      path: '/my_space',
      name: '我的空间',
      component: () => import('../pages/MySpacePage.vue'),
    },
    {
      path: '/space/:id',
      name: '空间详情',
      component: () => import('../pages/SpaceDetailPage.vue'),
      props: true,
    },

    {
      path: '/admin/manage',
      name: 'manage',
      component: () => import('../pages/admin/UserManagePage.vue'),
      meta: {
        access: ['admin'],
      },
    },
    {
      path: '/admin/add_picture_batch',
      name: 'addPictureBatch',
      component: () => import('../pages/admin/AddPictureBatchPage.vue'),
      meta: {
        access: ['admin'],
      },
    },
    {
      path: '/admin/picture_manage',
      name: 'picture_manage',
      component: () => import('../pages/admin/PictureManagePage.vue'),
      meta: {
        access: ['admin'],
      },
    },
    {
      path: `/add_picture`,
      name: 'add_picture',
      component: () => import('../pages/AddPicturePage.vue'),
      meta: {
        access: ['user'],
      },
    },
    {
      path: `/add_space`,
      name: 'add_space',
      component: () => import('../pages/AddSpacePage.vue'),
      meta: {
        access: ['user'],
      },
    },
    {
      path: '/picture/:id',
      name: '图片详情',
      component: () => import('../pages/PictureDetailPage.vue'),
      props: true,
    },
    {
      path: '/admin/space_manage',
      name: 'space_manage',
      component: () => import('../pages/SpaceManagePage.vue'),
      meta: {
        access: ['admin'],
      },
    },
  ],
})

export default router
